
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <title>switchMap · 学习 RxJS 操作符</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.1.1">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="window.html" />
    
    
    <link rel="prev" href="scan.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"star","size":"small","count":true},{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"fork","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <a target="_blank" href="https://github.com/RxJS-CN/learn-rxjs-operators">
            
                    
                    学习 RxJS 操作符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../about/README.md">
            
                <span>
            
                    
                    关于中文版
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">学习 RxJS</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../">
            
                <a href="../../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../">
            
                <a href="../">
            
                    
                    操作符
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../combination/">
            
                <a href="../combination/">
            
                    
                    组合
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1.1" data-path="../combination/combineall.html">
            
                <a href="../combination/combineall.html">
            
                    
                    combineAll
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.2" data-path="../combination/combinelatest.html">
            
                <a href="../combination/combinelatest.html">
            
                    
                    combineLatest
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.3" data-path="../combination/concat.html">
            
                <a href="../combination/concat.html">
            
                    
                    concat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.4" data-path="../combination/concatall.html">
            
                <a href="../combination/concatall.html">
            
                    
                    concatAll
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.5" data-path="../combination/forkjoin.html">
            
                <a href="../combination/forkjoin.html">
            
                    
                    forkJoin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.6" data-path="../combination/merge.html">
            
                <a href="../combination/merge.html">
            
                    
                    merge
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.7" data-path="../combination/mergeall.html">
            
                <a href="../combination/mergeall.html">
            
                    
                    mergeAll
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.8" data-path="../combination/pairwise.html">
            
                <a href="../combination/pairwise.html">
            
                    
                    pairwise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.9" data-path="../combination/race.html">
            
                <a href="../combination/race.html">
            
                    
                    race
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.10" data-path="../combination/startwith.html">
            
                <a href="../combination/startwith.html">
            
                    
                    startWith
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.11" data-path="../combination/withlatestfrom.html">
            
                <a href="../combination/withlatestfrom.html">
            
                    
                    withLatestFrom
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.12" data-path="../combination/zip.html">
            
                <a href="../combination/zip.html">
            
                    
                    zip
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../conditional/">
            
                <a href="../conditional/">
            
                    
                    条件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.2.1" data-path="../conditional/defaultifempty.html">
            
                <a href="../conditional/defaultifempty.html">
            
                    
                    defaultIfEmpty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2.2" data-path="../conditional/every.html">
            
                <a href="../conditional/every.html">
            
                    
                    every
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../creation/">
            
                <a href="../creation/">
            
                    
                    创建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.3.1" data-path="../creation/create.html">
            
                <a href="../creation/create.html">
            
                    
                    create
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.2" data-path="../creation/empty.html">
            
                <a href="../creation/empty.html">
            
                    
                    empty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.3" data-path="../creation/from.html">
            
                <a href="../creation/from.html">
            
                    
                    from
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.4" data-path="../creation/fromevent.html">
            
                <a href="../creation/fromevent.html">
            
                    
                    fromEvent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.5" data-path="../creation/frompromise.html">
            
                <a href="../creation/frompromise.html">
            
                    
                    fromPromise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.6" data-path="../creation/interval.html">
            
                <a href="../creation/interval.html">
            
                    
                    interval
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.7" data-path="../creation/of.html">
            
                <a href="../creation/of.html">
            
                    
                    of
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.8" data-path="../creation/range.html">
            
                <a href="../creation/range.html">
            
                    
                    range
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.9" data-path="../creation/throw.html">
            
                <a href="../creation/throw.html">
            
                    
                    throw
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.10" data-path="../creation/timer.html">
            
                <a href="../creation/timer.html">
            
                    
                    timer
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../error_handling/">
            
                <a href="../error_handling/">
            
                    
                    错误处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.4.1" data-path="../error_handling/catch.html">
            
                <a href="../error_handling/catch.html">
            
                    
                    catchError
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4.2" data-path="../error_handling/retry.html">
            
                <a href="../error_handling/retry.html">
            
                    
                    retry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4.3" data-path="../error_handling/retrywhen.html">
            
                <a href="../error_handling/retrywhen.html">
            
                    
                    retryWhen
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../multicasting/">
            
                <a href="../multicasting/">
            
                    
                    多播
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.5.1" data-path="../multicasting/publish.html">
            
                <a href="../multicasting/publish.html">
            
                    
                    publish
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.2" data-path="../multicasting/multicast.html">
            
                <a href="../multicasting/multicast.html">
            
                    
                    multicast
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.3" data-path="../multicasting/share.html">
            
                <a href="../multicasting/share.html">
            
                    
                    share
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.4" data-path="../multicasting/sharereplay.html">
            
                <a href="../multicasting/sharereplay.html">
            
                    
                    shareReplay
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="../filtering/">
            
                <a href="../filtering/">
            
                    
                    过滤
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.6.1" data-path="../filtering/debounce.html">
            
                <a href="../filtering/debounce.html">
            
                    
                    debounce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.2" data-path="../filtering/debouncetime.html">
            
                <a href="../filtering/debouncetime.html">
            
                    
                    debounceTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.3" data-path="../filtering/distinctuntilchanged.html">
            
                <a href="../filtering/distinctuntilchanged.html">
            
                    
                    distinctUntilChanged
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.4" data-path="../filtering/filter.html">
            
                <a href="../filtering/filter.html">
            
                    
                    filter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.5" data-path="../filtering/first.html">
            
                <a href="../filtering/first.html">
            
                    
                    first
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.6" data-path="../filtering/ignoreelements.html">
            
                <a href="../filtering/ignoreelements.html">
            
                    
                    ignoreElements
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.7" data-path="../filtering/last.html">
            
                <a href="../filtering/last.html">
            
                    
                    last
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.8" data-path="../filtering/sample.html">
            
                <a href="../filtering/sample.html">
            
                    
                    sample
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.9" data-path="../filtering/single.html">
            
                <a href="../filtering/single.html">
            
                    
                    single
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.10" data-path="../filtering/skip.html">
            
                <a href="../filtering/skip.html">
            
                    
                    skip
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.11" data-path="../filtering/skipuntil.html">
            
                <a href="../filtering/skipuntil.html">
            
                    
                    skipUntil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.12" data-path="../filtering/skipwhile.html">
            
                <a href="../filtering/skipwhile.html">
            
                    
                    skipWhile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.13" data-path="../filtering/take.html">
            
                <a href="../filtering/take.html">
            
                    
                    take
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.14" data-path="../filtering/takeuntil.html">
            
                <a href="../filtering/takeuntil.html">
            
                    
                    takeUntil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.15" data-path="../filtering/takewhile.html">
            
                <a href="../filtering/takewhile.html">
            
                    
                    takeWhile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.16" data-path="../filtering/throttle.html">
            
                <a href="../filtering/throttle.html">
            
                    
                    throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.17" data-path="../filtering/throttletime.html">
            
                <a href="../filtering/throttletime.html">
            
                    
                    throttleTime
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.7" data-path="./">
            
                <a href="./">
            
                    
                    转换
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.7.1" data-path="buffer.html">
            
                <a href="buffer.html">
            
                    
                    buffer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.2" data-path="buffercount.html">
            
                <a href="buffercount.html">
            
                    
                    bufferCount
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.3" data-path="buffertime.html">
            
                <a href="buffertime.html">
            
                    
                    bufferTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.4" data-path="buffertoggle.html">
            
                <a href="buffertoggle.html">
            
                    
                    bufferToggle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.5" data-path="bufferwhen.html">
            
                <a href="bufferwhen.html">
            
                    
                    bufferWhen
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.6" data-path="concatmap.html">
            
                <a href="concatmap.html">
            
                    
                    concatMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.7" data-path="concatmapto.html">
            
                <a href="concatmapto.html">
            
                    
                    concatMapTo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.8" data-path="exhaustmap.html">
            
                <a href="exhaustmap.html">
            
                    
                    exhaustMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.9" data-path="expand.html">
            
                <a href="expand.html">
            
                    
                    expand
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.10" data-path="exhaustmap.html">
            
                <a href="exhaustmap.html">
            
                    
                    exhaustMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.11" data-path="groupby.html">
            
                <a href="groupby.html">
            
                    
                    groupBy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.12" data-path="map.html">
            
                <a href="map.html">
            
                    
                    map
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.13" data-path="mapto.html">
            
                <a href="mapto.html">
            
                    
                    mapTo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.14" data-path="mergemap.html">
            
                <a href="mergemap.html">
            
                    
                    mergeMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.15" data-path="partition.html">
            
                <a href="partition.html">
            
                    
                    partition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.16" data-path="pluck.html">
            
                <a href="pluck.html">
            
                    
                    pluck
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.17" data-path="reduce.html">
            
                <a href="reduce.html">
            
                    
                    reduce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.18" data-path="scan.html">
            
                <a href="scan.html">
            
                    
                    scan
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.2.7.19" data-path="switchmap.html">
            
                <a href="switchmap.html">
            
                    
                    switchMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.20" data-path="window.html">
            
                <a href="window.html">
            
                    
                    window
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.21" data-path="windowcount.html">
            
                <a href="windowcount.html">
            
                    
                    windowCount
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.22" data-path="windowtime.html">
            
                <a href="windowtime.html">
            
                    
                    windowTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.23" data-path="windowtoggle.html">
            
                <a href="windowtoggle.html">
            
                    
                    windowToggle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.24" data-path="windowwhen.html">
            
                <a href="windowwhen.html">
            
                    
                    windowWhen
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.8" data-path="../utility/">
            
                <a href="../utility/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.8.1" data-path="../utility/do.html">
            
                <a href="../utility/do.html">
            
                    
                    do
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.2" data-path="../utility/delay.html">
            
                <a href="../utility/delay.html">
            
                    
                    delay
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.3" data-path="../utility/delaywhen.html">
            
                <a href="../utility/delaywhen.html">
            
                    
                    delayWhen
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.4" data-path="../utility/dematerialize.html">
            
                <a href="../utility/dematerialize.html">
            
                    
                    dematerialize
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.5" data-path="../utility/let.html">
            
                <a href="../utility/let.html">
            
                    
                    let
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.6" data-path="../utility/timeout.html">
            
                <a href="../utility/timeout.html">
            
                    
                    timeout
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.7" data-path="../utility/topromise.html">
            
                <a href="../utility/topromise.html">
            
                    
                    toPromise
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.9" data-path="../complete.html">
            
                <a href="../complete.html">
            
                    
                    完整列表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../../recipes/">
            
                <a href="../../recipes/">
            
                    
                    食谱
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../../recipes/smartcounter.html">
            
                <a href="../../recipes/smartcounter.html">
            
                    
                    智能计数器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../../recipes/progressbar.html">
            
                <a href="../../recipes/progressbar.html">
            
                    
                    进度条
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../../recipes/gameloop.html">
            
                <a href="../../recipes/gameloop.html">
            
                    
                    游戏循环
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../../concepts/">
            
                <a href="../../concepts/">
            
                    
                    概念
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../../concepts/rxjs5-6.html">
            
                <a href="../../concepts/rxjs5-6.html">
            
                    
                    RxJS v5 -> v6 升级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../../concepts/operator-imports.html">
            
                <a href="../../concepts/operator-imports.html">
            
                    
                    理解操作符导入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >switchMap</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="switchmap">switchMap</h1>
<h4 id="&#x51FD;&#x6570;&#x7B7E;&#x540D;-switchmapproject-function-observable-resultselector-functionoutervalue-innervalue-outerindex-innerindex-any-observable">&#x51FD;&#x6570;&#x7B7E;&#x540D;: <code>switchMap(project: function: Observable, resultSelector: function(outerValue, innerValue, outerIndex, innerIndex): any): Observable</code></h4>
<h2 id="&#x6620;&#x5C04;&#x6210;-observable&#xFF0C;&#x5B8C;&#x6210;&#x524D;&#x4E00;&#x4E2A;&#x5185;&#x90E8;-observable&#xFF0C;&#x53D1;&#x51FA;&#x503C;&#x3002;">&#x6620;&#x5C04;&#x6210; observable&#xFF0C;&#x5B8C;&#x6210;&#x524D;&#x4E00;&#x4E2A;&#x5185;&#x90E8; observable&#xFF0C;&#x53D1;&#x51FA;&#x503C;&#x3002;</h2>
<hr>
<p><img align="absmiddle" alt=":bulb:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/bulb.png" title=":bulb:"> &#x5982;&#x679C;&#x4F60;&#x60F3;&#x8981;&#x7EF4;&#x62A4;&#x591A;&#x4E2A;&#x5185;&#x90E8; subscription &#x7684;&#x8BDD;&#xFF0C; &#x8BF7;&#x5C1D;&#x8BD5; <a href="mergemap.html"><code>mergeMap</code></a>&#xFF01;</p>
<p><img align="absmiddle" alt=":bulb:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/bulb.png" title=":bulb:"> &#x6B64;&#x64CD;&#x4F5C;&#x7B26;&#x901A;&#x5E38;&#x88AB;&#x8BA4;&#x4E3A;&#x662F; <a href="mergemap.html"><code>mergeMap</code></a> &#x7684;&#x5B89;&#x5168;&#x7248;&#x672C;&#xFF01;</p>
<p><img align="absmiddle" alt=":bulb:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/bulb.png" title=":bulb:"> &#x6B64;&#x64CD;&#x4F5C;&#x7B26;&#x53EF;&#x4EE5;&#x53D6;&#x6D88;&#x6B63;&#x5728;&#x8FDB;&#x884C;&#x4E2D;&#x7684;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#xFF01;</p>
<hr>
<h3 id="&#x4E3A;&#x4EC0;&#x4E48;&#x4F7F;&#x7528;-switchmap&#xFF1F;">&#x4E3A;&#x4EC0;&#x4E48;&#x4F7F;&#x7528; <code>switchMap</code>&#xFF1F;</h3>
<p><code>switchMap</code> &#x548C;&#x5176;&#x4ED6;&#x6253;&#x5E73;&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x4E3B;&#x8981;&#x533A;&#x522B;&#x662F;&#x5B83;&#x5177;&#x6709;&#x53D6;&#x6D88;&#x6548;&#x679C;&#x3002;&#x5728;&#x6BCF;&#x6B21;&#x53D1;&#x51FA;&#x65F6;&#xFF0C;&#x4F1A;&#x53D6;&#x6D88;&#x524D;&#x4E00;&#x4E2A;&#x5185;&#x90E8; observable (&#x4F60;&#x6240;&#x63D0;&#x4F9B;&#x51FD;&#x6570;&#x7684;&#x7ED3;&#x679C;) &#x7684;&#x8BA2;&#x9605;&#xFF0C;&#x7136;&#x540E;&#x8BA2;&#x9605;&#x4E00;&#x4E2A;&#x65B0;&#x7684; observable &#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x77ED;&#x8BED;<strong>&#x5207;&#x6362;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x7684; observable</strong>&#x6765;&#x8BB0;&#x5FC6;&#x5B83;&#x3002;</p>
<p>&#x5B83;&#x80FD;&#x5728;&#x50CF; <a href="https://angular-2-training-book.rangle.io/handout/http/search_with_switchmap.html" target="_blank">typeaheads</a> &#x8FD9;&#x6837;&#x7684;&#x573A;&#x666F;&#x4E0B;&#x5B8C;&#x7F8E;&#x4F7F;&#x7528;&#xFF0C;&#x5F53;&#x6709;&#x65B0;&#x7684;&#x8F93;&#x5165;&#x65F6;&#x4FBF;&#x4E0D;&#x518D;&#x5173;&#x5FC3;&#x4E4B;&#x524D;&#x8BF7;&#x6C42;&#x7684;&#x54CD;&#x5E94;&#x7ED3;&#x679C;&#x3002;&#x5728;&#x5185;&#x90E8; observable &#x957F;&#x671F;&#x5B58;&#x6D3B;&#x53EF;&#x80FD;&#x4F1A;&#x5BFC;&#x81F4;&#x5185;&#x5B58;&#x6CC4;&#x9732;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x8FD9;&#x4E5F;&#x662F;&#x4E00;&#x79CD;&#x5B89;&#x5168;&#x7684;&#x9009;&#x62E9;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528; <a href="mergemap.html">mergeMap</a> &#x548C; interval&#xFF0C;&#x5E76;&#x5FD8;&#x8BB0;&#x6B63;&#x786E;&#x5904;&#x7406;&#x5185;&#x90E8;&#x8BA2;&#x9605;&#x3002;&#x8BB0;&#x4F4F;&#xFF0C;<code>switchMap</code> &#x540C;&#x4E00;&#x65F6;&#x95F4;&#x53EA;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A;&#x5185;&#x90E8;&#x8BA2;&#x9605;&#xFF0C;&#x5728;<a href="#%E7%A4%BA%E4%BE%8B-1-%E6%AF%8F5%E7%A7%92%E9%87%8D%E6%96%B0%E5%90%AF%E5%8A%A8-interval">&#x793A;&#x4F8B; 1</a>&#x4E2D;&#x53EF;&#x4EE5;&#x6E05;&#x695A;&#x51FA;&#x770B;&#x5230;&#x8FD9;&#x4E00;&#x70B9;&#x3002;</p>
<p>&#x4E0D;&#x8FC7;&#x8981;&#x5C0F;&#x5FC3;&#xFF0C;&#x5728;&#x6BCF;&#x4E2A;&#x8BF7;&#x6C42;&#x90FD;&#x9700;&#x8981;&#x5B8C;&#x6210;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x8003;&#x8651;&#x5199;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x4F60;&#x53EF;&#x80FD;&#x8981;&#x907F;&#x514D;&#x4F7F;&#x7528; <code>switchMap</code> &#x3002;&#x5982;&#x679C;&#x6E90; observable &#x53D1;&#x51FA;&#x901F;&#x5EA6;&#x8DB3;&#x591F;&#x5FEB;&#x7684;&#x8BDD;&#xFF0C;<code>switchMap</code> &#x53EF;&#x4EE5;&#x53D6;&#x6D88;&#x8BF7;&#x6C42;&#x3002;&#x5728;&#x8FD9;&#x4E9B;&#x573A;&#x666F;&#x4E2D;&#xFF0C;<a href="mergemap.html">mergeMap</a> &#x662F;&#x6B63;&#x786E;&#x7684;&#x9009;&#x62E9;&#x3002;</p>
<div class="ua-ad"><a href="https://ultimateangular.com/?ref=76683_kee7y7vk" target="_blank"><img src="https://ultimateangular.com/assets/img/banners/ua-leader.svg"></a></div>

<h3 id="&#x793A;&#x4F8B;">&#x793A;&#x4F8B;</h3>
<h5 id="&#x793A;&#x4F8B;-1-&#x6BCF;5&#x79D2;&#x91CD;&#x65B0;&#x542F;&#x52A8;-interval">&#x793A;&#x4F8B; 1: &#x6BCF;5&#x79D2;&#x91CD;&#x65B0;&#x542F;&#x52A8; interval</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-eb62ap?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/birepuveya/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/6pz981gd/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> timer<span class="token punctuation">,</span> interval <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> switchMap <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x7ACB;&#x5373;&#x53D1;&#x51FA;&#x503C;&#xFF0C; &#x7136;&#x540E;&#x6BCF;5&#x79D2;&#x53D1;&#x51FA;&#x503C;</span>
<span class="token keyword">const</span> source <span class="token operator">=</span> <span class="token function">timer</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">5000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5F53; source &#x53D1;&#x51FA;&#x503C;&#x65F6;&#x5207;&#x6362;&#x5230;&#x65B0;&#x7684;&#x5185;&#x90E8; observable&#xFF0C;&#x53D1;&#x51FA;&#x65B0;&#x7684;&#x5185;&#x90E8; observable &#x6240;&#x53D1;&#x51FA;&#x7684;&#x503C;</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> source<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">switchMap</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8F93;&#x51FA;: 0,1,2,3,4,5,6,7,8,9...0,1,2,3,4,5,6,7,8</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-2-&#x6BCF;&#x6B21;&#x70B9;&#x51FB;&#x65F6;&#x91CD;&#x7F6E;">&#x793A;&#x4F8B; 2: &#x6BCF;&#x6B21;&#x70B9;&#x51FB;&#x65F6;&#x91CD;&#x7F6E;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-s4pvix?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/zoruboxogo/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/y11v8aqz/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> interval<span class="token punctuation">,</span> fromEvent <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> switchMap<span class="token punctuation">,</span> mapTo <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x53D1;&#x51FA;&#x6BCF;&#x6B21;&#x70B9;&#x51FB;</span>
<span class="token keyword">const</span> source <span class="token operator">=</span> <span class="token function">fromEvent</span><span class="token punctuation">(</span>document<span class="token punctuation">,</span> <span class="token string">&apos;click&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5982;&#x679C;3&#x79D2;&#x5185;&#x53D1;&#x751F;&#x4E86;&#x53E6;&#x4E00;&#x6B21;&#x70B9;&#x51FB;&#xFF0C;&#x5219;&#x6D88;&#x606F;&#x4E0D;&#x4F1A;&#x88AB;&#x53D1;&#x51FA;</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> source<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>
  <span class="token function">switchMap</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">mapTo</span><span class="token punctuation">(</span><span class="token string">&apos;Hello, I made it!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// (&#x70B9;&#x51FB;)...3s...&apos;Hello I made it!&apos;...(&#x70B9;&#x51FB;)...2s(&#x70B9;&#x51FB;)...</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-3-&#x4F7F;&#x7528;-resultselector-&#x51FD;&#x6570;">&#x793A;&#x4F8B; 3: &#x4F7F;&#x7528; <code>resultSelector</code> &#x51FD;&#x6570;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-bmibzi?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/qobapubeze/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/nqfu534y/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> timer<span class="token punctuation">,</span> interval <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> switchMap <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x7ACB;&#x5373;&#x53D1;&#x51FA;&#x503C;&#xFF0C; &#x7136;&#x540E;&#x6BCF;5&#x79D2;&#x53D1;&#x51FA;&#x503C;</span>
<span class="token keyword">const</span> source <span class="token operator">=</span> <span class="token function">timer</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">5000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5F53; source &#x53D1;&#x51FA;&#x503C;&#x65F6;&#x5207;&#x6362;&#x5230;&#x65B0;&#x7684;&#x5185;&#x90E8; observable&#xFF0C;&#x8C03;&#x7528;&#x6295;&#x5C04;&#x51FD;&#x6570;&#x5E76;&#x53D1;&#x51FA;&#x503C;</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> source<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>
  <span class="token function">switchMap</span><span class="token punctuation">(</span>
    _ <span class="token operator">=&gt;</span> <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">(</span>outerValue<span class="token punctuation">,</span> innerValue<span class="token punctuation">,</span> outerIndex<span class="token punctuation">,</span> innerIndex<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">(</span><span class="token punctuation">{</span>
      outerValue<span class="token punctuation">,</span>
      innerValue<span class="token punctuation">,</span>
      outerIndex<span class="token punctuation">,</span>
      innerIndex
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">/*
    &#x8F93;&#x51FA;:
    {outerValue: 0, innerValue: 0, outerIndex: 0, innerIndex: 0}
    {outerValue: 0, innerValue: 1, outerIndex: 0, innerIndex: 1}
    {outerValue: 1, innerValue: 0, outerIndex: 1, innerIndex: 0}
    {outerValue: 1, innerValue: 1, outerIndex: 1, innerIndex: 1}
*/</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-4-&#x4F7F;&#x7528;-switchmap-&#x7684;&#x5012;&#x8BA1;&#x65F6;&#x5B9A;&#x65F6;&#x5668;">&#x793A;&#x4F8B; 4: &#x4F7F;&#x7528; switchMap &#x7684;&#x5012;&#x8BA1;&#x65F6;&#x5B9A;&#x65F6;&#x5668;</h5>
<p>( <a href="https://stackblitz.com/edit/typescript-ivdebg?file=index.ts" target="_blank">StackBlitz</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> interval<span class="token punctuation">,</span> fromEvent<span class="token punctuation">,</span> merge<span class="token punctuation">,</span> empty <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> switchMap<span class="token punctuation">,</span> scan<span class="token punctuation">,</span> takeWhile<span class="token punctuation">,</span> startWith<span class="token punctuation">,</span> mapTo <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> countdownSeconds <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> <span class="token function-variable function">setHTML</span> <span class="token operator">=</span> id <span class="token operator">=&gt;</span> val <span class="token operator">=&gt;</span> <span class="token punctuation">(</span>document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">.</span>innerHTML <span class="token operator">=</span> val<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> pauseButton <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">&apos;pause&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> resumeButton <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">&apos;resume&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> interval$ <span class="token operator">=</span> <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">mapTo</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> pause$ <span class="token operator">=</span> <span class="token function">fromEvent</span><span class="token punctuation">(</span>pauseButton<span class="token punctuation">,</span> <span class="token string">&apos;click&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">mapTo</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> resume$ <span class="token operator">=</span> <span class="token function">fromEvent</span><span class="token punctuation">(</span>resumeButton<span class="token punctuation">,</span> <span class="token string">&apos;click&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">mapTo</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> timer$ <span class="token operator">=</span> <span class="token function">merge</span><span class="token punctuation">(</span>pause$<span class="token punctuation">,</span> resume$<span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>
    <span class="token function">startWith</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">switchMap</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> <span class="token punctuation">(</span>val <span class="token operator">?</span> interval$ <span class="token punctuation">:</span> <span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">scan</span><span class="token punctuation">(</span><span class="token punctuation">(</span>acc<span class="token punctuation">,</span> curr<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">(</span>curr <span class="token operator">?</span> curr <span class="token operator">+</span> acc <span class="token punctuation">:</span> acc<span class="token punctuation">)</span><span class="token punctuation">,</span> countdownSeconds<span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">takeWhile</span><span class="token punctuation">(</span>v <span class="token operator">=&gt;</span> v <span class="token operator">&gt;=</span> <span class="token number">0</span><span class="token punctuation">)</span>
  <span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span><span class="token function">setHTML</span><span class="token punctuation">(</span><span class="token string">&apos;remaining&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h6 id="html">HTML</h6>
<pre class="language-"><code class="lang-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">&gt;</span></span>
Time remaining: <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>remaining<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>pause<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
Pause Timer
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>resume<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
Resume Timer
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h3 id="&#x76F8;&#x5173;&#x98DF;&#x8C31;">&#x76F8;&#x5173;&#x98DF;&#x8C31;</h3>
<ul>
<li><a href="../../recipes/smartcounter.html">&#x667A;&#x80FD;&#x8BA1;&#x6570;&#x5668;</a></li>
<li><a href="../../recipes/progressbar.html">&#x8FDB;&#x5EA6;&#x6761;</a></li>
<li><a href="../../recipes/http-polling.md">HTTP &#x8F6E;&#x8BE2;</a></li>
</ul>
<h3 id="&#x5176;&#x4ED6;&#x8D44;&#x6E90;">&#x5176;&#x4ED6;&#x8D44;&#x6E90;</h3>
<ul>
<li><a href="http://cn.rx.js.org/class/es6/Observable.js~Observable.html#instance-method-switchMap" target="_blank">switchMap</a> <img align="absmiddle" alt=":newspaper:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/newspaper.png" title=":newspaper:"> - &#x5B98;&#x65B9;&#x6587;&#x6863;</li>
<li><a href="https://blog.angularindepth.com/switchmap-bugs-b6de69155524" target="_blank">&#x907F;&#x514D; switchMap &#x7684;&#x76F8;&#x5173; Bugs</a> - Nicholas Jamieson</li>
<li><a href="https://egghead.io/lessons/rxjs-starting-a-stream-with-switchmap?course=step-by-step-async-javascript-with-rxjs" target="_blank">&#x4F7F;&#x7528; switchMap &#x5F00;&#x542F;&#x6D41;</a> <img align="absmiddle" alt=":video_camera:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/video_camera.png" title=":video_camera:"> <img align="absmiddle" alt=":dollar:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/dollar.png" title=":dollar:"> - John Linquist</li>
<li><a href="https://egghead.io/lessons/rxjs-use-rxjs-switchmap-to-map-and-flatten-higher-order-observables?course=use-higher-order-observables-in-rxjs-effectively" target="_blank">&#x4F7F;&#x7528; RxJS &#x7684; switchMap &#x64CD;&#x4F5C;&#x7B26;&#x6765;&#x6620;&#x5C04;&#x5E76;&#x6253;&#x5E73;&#x9AD8;&#x9636; observables</a> <img align="absmiddle" alt=":video_camera:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/video_camera.png" title=":video_camera:"> <img align="absmiddle" alt=":dollar:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/dollar.png" title=":dollar:"> - Andr&#xE9; Staltz</li>
<li><a href="https://egghead.io/lessons/rxjs-use-switchmap-as-a-safe-default-to-flatten-observables-in-rxjs?course=use-higher-order-observables-in-rxjs-effectively" target="_blank">&#x5728; RxJS &#x4E2D;&#xFF0C;&#x4F7F;&#x7528; switchMap &#x4F5C;&#x4E3A;&#x6253;&#x5E73; observables &#x7684;&#x5B89;&#x5168;&#x9ED8;&#x8BA4;&#x64CD;&#x4F5C;&#x7B26;</a> <img align="absmiddle" alt=":video_camera:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/video_camera.png" title=":video_camera:"> <img align="absmiddle" alt=":dollar:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/dollar.png" title=":dollar:"> - Andr&#xE9; Staltz</li>
</ul>
<hr>
<blockquote>
<p><img align="absmiddle" alt=":file_folder:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/file_folder.png" title=":file_folder:"> &#x6E90;&#x7801;:  <a href="https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/switchMap.ts" target="_blank">https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/switchMap.ts</a></p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="scan.html" class="navigation navigation-prev " aria-label="Previous page: scan">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="window.html" class="navigation navigation-next " aria-label="Next page: window">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"switchMap","level":"2.2.7.19","depth":3,"next":{"title":"window","level":"2.2.7.20","depth":3,"path":"operators/transformation/window.md","ref":"operators/transformation/window.md","articles":[]},"previous":{"title":"scan","level":"2.2.7.18","depth":3,"path":"operators/transformation/scan.md","ref":"operators/transformation/scan.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","advanced-emoji","prism","highlight","copy-code-button","edit-link","github","github-buttons"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/RxJS-CN/learn-rxjs-operators"},"search":{},"lunr":{"maxIndexSize":1000000},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"github-buttons":{"buttons":[{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"star","size":"small","count":true},{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"fork","size":"small","count":true}]},"copy-code-button":{},"advanced-emoji":{"embedEmojis":false},"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"帮忙纠错","base":"https://github.com/RxJS-CN/learn-rxjs-operators/tree/master"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"index.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"学习 RxJS 操作符","gitbook":"3.1.1"},"file":{"path":"operators/transformation/switchmap.md","mtime":"2018-10-15T09:07:06.000Z","type":"markdown"},"gitbook":{"version":"3.1.1","time":"2018-10-15T09:31:22.754Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

